//本地存储
let local = {
  save (key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  },
  fetch (key) {
    return JSON.parse(localStorage.getItem(key)) || {}
  },
  removeItem(key){
  	return localStorage.removeItem(key);
  },
  clear(){
  	 localStorage.clear()   
  }
}

//浏览器存储
let session = {
  save (key, value) {
    sessionStorage.setItem(key, JSON.stringify(value))
  },
  fetch (key) {
    return JSON.parse(sessionStorage.getItem(key)) || {}
  },
  removeItem(key){
  	return sessionStorage.removeItem(key);
  },
  clear(){
  	 sessionStorage.clear()   
  }
}

export default {
	install:function(vm){
		vm.prototype.$local = local ; 
		vm.prototype.$session = session ;
	}
}